package io.netty.example.mytest.io;

import java.io.InputStream;
import java.io.OutputStream;
import java.net.Socket;

/**
 * @ClassName BioClient
 * @Description TODO
 * @Author dukezeng
 * @CreatedTime 2019/4/13 15:53
 * @Version 1.0
 **/
public class BioClient {
    public static void main(String[] args) {
        new BioClient().start();
    }

    public void start() {
        try {
            Socket socket = new Socket("127.0.0.1", 99);

            OutputStream outputStream = socket.getOutputStream();
            outputStream.write("hello server".getBytes());

            InputStream inputStream = socket.getInputStream();
            byte[] buffer = new byte[1024];
            inputStream.read(buffer);
            System.out.println("服务器响应：" + new String(buffer));

            inputStream.close();
            outputStream.close();
            socket.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
